package com.ryskoo.cms.customerservice.service;

import com.ryskoo.cms.customerservice.domain.CustomerServicePO;
import com.ryskoo.cms.customerservice.repository.ICustomerServiceRepository;
import com.ryskoo.framework.core.service.BasicServiceImpl;
import com.ryskoo.framework.core.utils.DateFormatHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author renyuting
 * @data 2018-04-23
 */
@Service
public class CustomerServiceServiceImpl extends BasicServiceImpl<CustomerServicePO> implements ICustomerServiceService{
    @Autowired
    private ICustomerServiceRepository customerServiceRepository;

    @PostConstruct
    public void init(){
        this.setDao(customerServiceRepository);
    }

    @Override
    public void create(CustomerServicePO customerServicePO) {
        customerServicePO.setCreateTime(DateFormatHelper.getNowTimeStr());
        super.create(customerServicePO);
    }

    @Override
    public void update(CustomerServicePO customerServicePO) {
        CustomerServicePO customerServicePONew = this.getByUuid(customerServicePO.getUuid());
        if(customerServicePONew != null){
            customerServicePONew.setName(customerServicePO.getName());
            customerServicePONew.setNumber(customerServicePO.getNumber());
            customerServicePONew.setType(customerServicePO.getType());
            customerServicePONew.setSortValue(customerServicePO.getSortValue());
        }
        super.update(customerServicePONew);
    }
}
